#include<iostream>
using namespace std;
int Search_Bin(int a[],int n,int key);
template <class T>int length(T &arr);
int main()
{
    int array[]={0,2,3,4,5,8};
    int key=8,result;
    result=Search_Bin(array,length(array),key);
    cout<<"查找结果:"<<result<<endl;
}
int Search_Bin(int a[],int n,int key)
{
    int low=1;
    int high=n;
    while (low<=high)
    {
        int mid=(low+high)/2;
        if(key==a[mid])
            return mid;
        else if(key<a[mid])
            high=mid-1;
        else
            low=mid+1;
    }
    return 0;
}
template <class T>int length(T &arr)
{
    return sizeof(arr)/sizeof(arr[0]);
}